home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / vm / vmBoot.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  2.6 KB  |  107 lines

  1. /* vmBoot.c -
  2.  *
  3.  *    This file contains routines that allocate memory for tables at boot 
  4.  *    time.
  5.  *
  6.  * Copyright (C) 1985 Regents of the University of California
  7.  * All rights reserved.
  8.  */
  9.  
  10. #ifndef lint
  11. static char rcsid[] = "$Header: /cdrom/src/kernel/Cvsroot/kernel/vm/vmBoot.c,v 9.4 92/07/22 16:55:13 jhh Exp $ SPRITE (Berkeley)";
  12. #endif not lint
  13.  
  14. #include <sprite.h>
  15. #include <sys.h>
  16. #include <vm.h>
  17. #include <vmInt.h>
  18. #include <bstring.h>
  19.  
  20. Address    vmMemEnd;
  21. Address vmBootEnd;
  22. Boolean    vmNoBootAlloc = TRUE;
  23.  
  24.  
  25. /*
  26.  * ----------------------------------------------------------------------------
  27.  *
  28.  * Vm_BootInit --
  29.  *
  30.  *    Initialize virtual memory and the variable that determines 
  31.  *    where to start allocating memory at boot time.
  32.  *
  33.  * Results:
  34.  *    None.
  35.  *
  36.  * Side effects:
  37.  *         vmMemEnd is set and several variables are set by the machine dependent
  38.  *    boot routine.
  39.  *
  40.  * ----------------------------------------------------------------------------
  41.  */
  42. void
  43. Vm_BootInit()
  44. {
  45.     extern unsigned int end;
  46.  
  47.     /* 
  48.      * Don't bother initializing vmStat.minFSPages.  During booting it
  49.      * will get set to 0 or 1, which isn't interesting.  So we will
  50.      * put something in the bootcmds script to set minFSPages to the
  51.      * current cache size after the system has finished booting.
  52.      */
  53.     bzero((Address) &vmStat, sizeof(vmStat));
  54.  
  55.     vmNoBootAlloc = FALSE;
  56.     vmMemEnd = (Address) &end;
  57.     /*
  58.      * Make sure that we start on a four byte boundary.
  59.      */
  60. #ifdef sun4        /* temporary test - this will not last */
  61.     vmMemEnd = (Address) (((int) vmMemEnd + 7) & ~7);    /* double-word bound. */
  62. #else
  63.     vmMemEnd = (Address) (((int) vmMemEnd + 3) & ~3);
  64. #endif /* sun4 */
  65.  
  66.     VmMach_BootInit(&vm_PageSize, &vmPageShift, &vmPageTableInc,
  67.             &vmKernMemSize, &vmStat.numPhysPages, &vmMaxMachSegs,
  68.             &vmMaxProcesses);
  69. }
  70.  
  71.  
  72. /*
  73.  * ----------------------------------------------------------------------------
  74.  *
  75.  * Vm_BootAlloc --
  76.  *
  77.  *     Allocate a block of memory of the given size starting at the
  78.  *     current end of kernel memory.
  79.  *
  80.  * Results:
  81.  *     A pointer to the allocated memory.
  82.  *
  83.  * Side effects:
  84.  *     vmMemEnd is incremented.
  85.  *
  86.  * ----------------------------------------------------------------------------
  87.  */
  88. Address
  89. Vm_BootAlloc(numBytes)
  90. int numBytes;
  91. {
  92.     Address    addr;
  93.  
  94.     if (vmNoBootAlloc) {
  95.     panic("Trying to use Vm_BootAlloc either before calling Vm_BootAllocInit\r\nor after calling Vm_Init\r\n");
  96.     addr = 0;
  97.     return(addr);
  98.     }
  99.     addr =  vmMemEnd;
  100. #ifdef sun4    /* temporary test - this will not last */
  101.     vmMemEnd += (numBytes + 7) & ~7;    /* double-word boundary */
  102. #else
  103.     vmMemEnd += (numBytes + 3) & ~3;
  104. #endif /* sun4 */
  105.     return(addr);
  106. }
  107.